home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2008 February / PCWFEB08.iso / Software / Resources / Developers / XAMPP 1.5.4 / Windows installer / xampp-win32-1.5.4-installer.exe / xampp / php / pear / SOAP / Fault.php < prev    next >
Encoding:
PHP Script  |  2006-04-07  |  4.0 KB  |  136 lines

  1. <?php
  2. /**
  3.  * This file contains the SOAP_Fault class, used for all error objects in this
  4.  * package.
  5.  *
  6.  * PHP versions 4 and 5
  7.  *
  8.  * LICENSE: This source file is subject to version 2.02 of the PHP license,
  9.  * that is bundled with this package in the file LICENSE, and is available at
  10.  * through the world-wide-web at http://www.php.net/license/2_02.txt.  If you
  11.  * did not receive a copy of the PHP license and are unable to obtain it
  12.  * through the world-wide-web, please send a note to license@php.net so we can
  13.  * mail you a copy immediately.
  14.  *
  15.  * @category   Web Services
  16.  * @package    SOAP
  17.  * @author     Dietrich Ayala <dietrich@ganx4.com> Original Author
  18.  * @author     Shane Caraveo <Shane@Caraveo.com>   Port to PEAR and more
  19.  * @author     Chuck Hagenbuch <chuck@horde.org>   Maintenance
  20.  * @author     Jan Schneider <jan@horde.org>       Maintenance
  21.  * @copyright  2003-2005 The PHP Group
  22.  * @license    http://www.php.net/license/2_02.txt  PHP License 2.02
  23.  * @link       http://pear.php.net/package/SOAP
  24.  */
  25.  
  26. require_once('PEAR.php');
  27.  
  28. /**
  29.  * SOAP_Fault
  30.  * PEAR::Error wrapper used to match SOAP Faults to PEAR Errors
  31.  *
  32.  * @package  SOAP
  33.  * @access   public
  34.  * @author   Shane Caraveo <Shane@Caraveo.com>   Port to PEAR and more
  35.  * @author   Dietrich Ayala <dietrich@ganx4.com> Original Author
  36.  */
  37. class SOAP_Fault extends PEAR_Error
  38. {
  39.     
  40.     /**
  41.      * Constructor
  42.      * 
  43.      * @param    string  message string for fault
  44.      * @param    mixed   the faultcode
  45.      * @param    mixed   see PEAR::ERROR 
  46.      * @param    mixed   see PEAR::ERROR 
  47.      * @param    array   the userinfo array is used to pass in the
  48.      *                   SOAP actor and detail for the fault
  49.      */
  50.     function SOAP_Fault($faultstring = 'unknown error', $faultcode = 'Client', $faultactor=NULL, $detail=NULL, $mode = null, $options = null)
  51.     {
  52.         parent::PEAR_Error($faultstring, $faultcode, $mode, $options, $detail);
  53.         if ($faultactor) $this->error_message_prefix = $faultactor;
  54.     }
  55.     
  56.     /**
  57.      * message
  58.      *
  59.      * returns a SOAP_Message class that can be sent as a server response
  60.      *
  61.      * @return SOAP_Message 
  62.      * @access public
  63.      */
  64.     function message()
  65.     {
  66.         $msg =& new SOAP_Base();
  67.         $params = array();
  68.         $params[] =& new SOAP_Value('faultcode', 'QName', 'SOAP-ENV:'.$this->code);
  69.         $params[] =& new SOAP_Value('faultstring', 'string', $this->message);
  70.         $params[] =& new SOAP_Value('faultactor', 'anyURI', $this->error_message_prefix);
  71.         if (isset($this->backtrace)) {
  72.             $params[] =& new SOAP_Value('detail', 'string', $this->backtrace);
  73.         } else {
  74.             $params[] =& new SOAP_Value('detail', 'string', $this->userinfo);
  75.         }
  76.         
  77.         $methodValue =& new SOAP_Value('{'.SOAP_ENVELOP.'}Fault', 'Struct', $params);
  78.         $headers = NULL;
  79.         return $msg->_makeEnvelope($methodValue, $headers);
  80.     }
  81.     
  82.     /**
  83.      * getFault
  84.      *
  85.      * returns a simple native php array containing the fault data
  86.      *
  87.      * @return array 
  88.      * @access public
  89.      */
  90.     function getFault()
  91.     {
  92.         global $SOAP_OBJECT_STRUCT;
  93.         if ($SOAP_OBJECT_STRUCT) {
  94.             $fault =& new stdClass();
  95.             $fault->faultcode = $this->code;
  96.             $fault->faultstring = $this->message;
  97.             $fault->faultactor = $this->error_message_prefix;
  98.             $fault->detail = $this->userinfo;
  99.             return $fault;
  100.         }
  101.         return array(
  102.                 'faultcode' => $this->code,
  103.                 'faultstring' => $this->message,
  104.                 'faultactor' => $this->error_message_prefix,
  105.                 'detail' => $this->userinfo
  106.             );
  107.     }
  108.     
  109.     /**
  110.      * getActor
  111.      *
  112.      * returns the SOAP actor for the fault
  113.      *
  114.      * @return string 
  115.      * @access public
  116.      */
  117.     function getActor()
  118.     {
  119.         return $this->error_message_prefix;
  120.     }
  121.     
  122.     /**
  123.      * getDetail
  124.      *
  125.      * returns the fault detail
  126.      *
  127.      * @return string 
  128.      * @access public
  129.      */
  130.     function getDetail()
  131.     {
  132.         return $this->userinfo;
  133.     }
  134.     
  135. }
  136. ?>